package Work0507;

import java.util.Scanner;

public class CustomerBizTest {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		CustomerBiz test = new CustomerBiz();
		while (true) {
			System.out.println("1.增加新客户\t2.显示所有客户\t3.查找指定位置的姓名\t4.修改客户名\t5.按照范围查找\t6.查找客户\t9.退出");
			System.out.print("请输入序号：");
			int a = in.nextInt();
			if (a == 1) {
				System.out.print("请输入客户名称：");
				String name = in.next();
				test.addName(name);
				System.out.println();
			} else if (a == 2) {
				test.showName();
				System.out.println();
			} else if (a == 3) {
				System.out.print("请输入查找的序号：");
				int b = in.nextInt();
				String name = test.findName(b);
				System.out.println(name);
				System.out.println();
			} else if (a == 4) {
				System.out.print("请输入需要修改的名称：");
				String oldName = in.next();
				System.out.print("请输入修改后的名称：");
				String newName = in.next();
				boolean question = test.amendName(newName, oldName);
				System.out.println(question ? "修改成功" : "该客户不存在");
				System.out.println();
			} else if (a == 5) {
				System.out.print("请输入起始位置：");
				int e = in.nextInt();
				System.out.print("请输入末尾位置：");
				int f = in.nextInt();
				System.out.print("请输入需要查找的名字：");
				String name = in.next();
				boolean q = test.rangeName(e, f, name);
				System.out.println(q ? "客户存在" : "客户不存在");
				System.out.println();
			} else if (a == 6) {
				System.out.print("请输入要查找的姓名：");
				String findName = in.next();
				boolean w = test.search(findName);
				System.out.println(w ? "该用户存在" : "该用户不存在");
				System.out.println();
			} else if (a == 9) {
				break;
			}

		}

	}

}
